package com.andyage.admin.action;

import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.andyage.admin.bean.AdprojectapplyBean;
import com.andyage.admin.service.IAdprojectApplyService;
import com.andyage.util.TypeTransfor;

@Controller
@RequestMapping("/admin")
public class AdprojectApplyAction {
	@Resource
	private IAdprojectApplyService iadprojectApplyService;
	public  String CONTENT_TYPE="text/html;charset=utf-8";
	@RequestMapping("/queryAdprojectApplyInfo")
	public void queryAdprojectApplyInfo(HttpServletResponse response,AdprojectapplyBean projectapply) throws Exception {
		String json=iadprojectApplyService.queryAdprojectApplyInfo(projectapply);
		response.setContentType(CONTENT_TYPE);
		response.getWriter().print(json);
	}
	@RequestMapping("/updateAdprojectApplyInfo")
	public void updateAdprojectApplyInfo(HttpServletResponse response,AdprojectapplyBean projectapply,HttpServletRequest request) throws Exception {
		String spaStatus=request.getParameter("spaStatus");
		if(TypeTransfor.isNumber(spaStatus)){
			projectapply.setPaStatus(Integer.valueOf(spaStatus));
			projectapply.setPaVerifyTime(new Date());
		}else{
		 if(spaStatus!=null&&!spaStatus.equals("")){
			if(spaStatus.equals("待审核")){
				projectapply.setPaStatus(1);
			}
			if(spaStatus.equals("审核未通过")){
				projectapply.setPaStatus(3);
				projectapply.setPaVerifyTime(new Date());
			}
			if(spaStatus.equals("审核通过")){
				projectapply.setPaStatus(2);
				projectapply.setPaVerifyTime(new Date());
			}
		}
		}
		String result=iadprojectApplyService.updateAdprojectApplyInfo(projectapply,request);
		response.setContentType(CONTENT_TYPE);
		response.getWriter().print(result);
	}
}
